<?php session_start();?>
<?php


set_include_path('../140dev/db');
	
require_once('140dev_config.php');	  
require_once('db_lib.php');

if($_GET['login'] == "1"){
			
	$oDB = new db;
    
	if(!$oDB)
	{
		die('Could not connect: ' . mysql_error());
	}
	
	try{
		$result = $oDB->select("SELECT DS_USER_ID, DS_SALT, DS_PWD FROM MAST_USERS WHERE LOWER(DS_USER_ID) = TRIM(LOWER('" . $_POST['user_name'] . "'));");
		if($row = mysqli_fetch_row($result)){
			$user_name = $row[0];
			$salt = $row[1];			
			$hash = $row[2];
			echo $user_name . "<br>";
			echo $salt . "<br>";
			echo $hash . "<br>";
			echo  hash("sha256",  $_POST['user_password']  . $salt);
		}
	}
	catch(Exception $e){
		print $e;
	}	
	
	return;
}

//vars
$subject = "iRestauranting - Nuevo comentario - " . $_POST['name'];
$to = explode(',', "info@sygnium.com" );

$from = $_POST['email'];

//data
$msg = "NOMBRE: "  .$_POST['name']    ."<br>\n";
$msg .= "EMAIL: "  .$_POST['email']    ."<br>\n";
$msg .= "COMENTARIOS: "  .$_POST['message']    ."<br>\n";

if($_GET['alta'] == "1"){
	$subject = "iRestauranting - Nuevo usuario - " . $_POST['name'];
	
	$msg = "NOMBRE: "  .$_POST['name']    ."<br>\n";
	$msg .= "EMAIL: "  .$_POST['correo']    ."<br>\n";
	$msg .= "RESTAURANTE: "  .$_POST['restaurante']    ."<br>\n";
}


if(isset($_GET['nueva_func'])){
	$subject = "iRestauranting - Peticion de funcionalidad - " . $_POST['name'];
	
	$msg = "NOMBRE: "  . $_SESSION['username'] ."<br>\n";
	// $msg .= "EMAIL: "  . $_POST['correo']    ."<br>\n";
	// $msg .= "RESTAURANTE: "  . $_SESSION['restaurants']    ."<br>\n";
	$msg .= "FUNCIONALIDAD: "  .$_GET['nueva_func']    ."<br>\n";
}

//Headers
$headers  = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=UTF-8\r\n";
$headers .= "From: <info@sygnium.com>" ;
 
//send for each mail
foreach($to as $mail){
   mail($mail, $subject, $msg, $headers);
}

?>
